// TOWN SCRIPT
//    Town 16: Dargoth (after winning)

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documentation. States you write
// yourself should be numbered from 10-100.

// flags:
// 16, 0 = Intro dialog
// 16, 1 = Museum message
// 16, 2 = Storeroom message
// 16, 3 = Pool sign
// 16, 4 = Narn God message
// 16, 5 = Conversation flag
// 16, 6 = inn flag

begintownscript;

variables;

short choice, x, ds;

body;

beginstate INIT_STATE;
	turn_off_training(TRUE);
	set_crime_tolerance(5);

	set_name(6, "The Bishop");
	set_char_dialogue_pic(6, 1955, 0);
	set_name(14, "James");
	set_char_dialogue_pic(14, 1945, 0);
	set_name(21, "James");
	set_char_dialogue_pic(21, 1958, 0);
	set_name(22, "Jamie");
	set_char_dialogue_pic(22, 1947, 0);
	set_name(24, "Jamie");
	set_char_dialogue_pic(24, 1950, 0);
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
	if (get_flag(16, 0) == FALSE) {
		set_flag(16, 0, TRUE);
		reset_dialog();
		add_dialog_str(0, "You've entered the legendary city of Dargoth, home of the Temple of Narn.", 0);
		add_dialog_str(1, "The temple being the place where Turin created the Staff many centuries ago.", 0);
		add_dialog_str(2, "Dargoth is also where the staff is kept, The Wilderness protection.", 0);
		add_dialog_str(3, "The staff now sits where it always has, the museum now closed.", 0);
		add_dialog_str(4, "There is a sense of peace in the city, as if a great weight has been lifted from the land.", 0);
		add_dialog_choice(0, "Ok");
		choice = run_dialog(TRUE);
	}
break;

beginstate 10;
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
	block_entry(TRUE);
	if (get_flag(16, 1) == FALSE) {
		set_flag(16, 1, TRUE);
		reset_dialog();
		add_dialog_str(0, "As you attempt to go through the door, the guards on either side draw their weapons.", 0);
		add_dialog_str(1, "'Authorized personnel only' one of them says, preventing you from entering.", 0);
		add_dialog_str(2, "In the dim light, you can see the Staff of Turin, back on its stand.", 0);
		add_dialog_str(3, "It appears as if all of the traps and locks are re-enabled, protecting it once again.", 0);
		add_dialog_str(4, "You see James, who gives a brief wave, in the room watching, just watching.", 0);
		add_dialog_choice(0, "Ok");
		choice = run_dialog(TRUE);
	}
	else {
		if (char_ok(23) == TRUE) {
			message_dialog("The guard at the door prevents you from entering the room.", "");
		}
		else {
			message_dialog("A mysterious force prevents you from entering the room.",
				"The staff stays safe, snuggled in its stand.");
		}
	}
break;

beginstate 14;
	if (get_flag(16, 2) == FALSE) {
		set_flag(16, 2, TRUE);
		message_dialog("The storeroom is full of implements and tools used by the monks to tend the fields in and around Dargoth.",
				"");
	}
break;

beginstate 15;
	if (get_flag(16, 3) == FALSE) {
		set_flag(16, 3, TRUE);
		message_dialog("A small sign at the head of the pool says 'Meditation Pool'.", "Please be quiet.");
	}
break;

beginstate 16;
	if (get_flag(16, 4) == FALSE) {
		set_flag(16, 4, TRUE);
		message_dialog("There is a statue of the Narn God here.  The detail is exquisite.",
				"A small rug lays in front of the statue, possibly to pray or chant on.");
	}
	else {
		print_str_color("You are by the statue of the Narn God.", 2);
	}
break;

beginstate 17;
	if (get_flag(16, 6) > 0) {
		x = 36;
		ds = 3;
		set_state_continue(19);
	}
break;

beginstate 18;
	if (get_flag(16, 6) > 0) {
		x = 40;
		ds = 4;
		set_state_continue(19);
	}
break;

beginstate 19;
	set_flag(16, 6, FALSE);
	teleport_party(x, 41, 1);
	give_ter_script_message(ds, 1);
	revive_party();
	set_ticks_forward(1500);
	force_instant_terrain_redraw();
	message_dialog("The room was comfortable and relaxing.", "You awake feeling refreshed and ready for more.");
break;

beginstate 20;
	run_scenario_script(14);
break;

beginstate 21;
	run_scenario_script(15);
break;
